package LogThread;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class DayShcedule {
	public static void DayShceduleRun(){
		Timer timer = new Timer(false);
		
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.DATE,cal.get(Calendar.DATE)+1);
		cal.set(Calendar.HOUR,0);
		cal.set(Calendar.MINUTE,1);
		cal.set(Calendar.SECOND,0);
		
		timer.schedule(new DayWork(), new Date(cal.getTimeInMillis()),24*60*60*1000);
		
	}
	public static class DayWork extends TimerTask {

		@Override
		public void run() {
			try {
				Connector.toFileAppend();
				
				Calendar cal = Calendar.getInstance();
				if(cal.get(Calendar.DATE)==1){
					Connector.toMapReduce();
				}
				
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	}
}
